<?php if( $pager->haveToPaginate() ): ?>

    <?php $params = isset($params) ? $params : array();?>
    <?php $params = $params instanceof sfOutputEscaper ? $params->getRawValue() : $params;?> 
    <?php $anchor = isset($anchor) ? $anchor : '';?>
    
    <div class="pages-navigation">
        <?php if( !$pager->isFirstPage() ): ?>
        <a href="<?php echo url_for( $route, array_merge( $params, array( 'page' => $pager->getFirstPage() ) ) ) . $anchor ?>" class="button first"></a>
        <a href="<?php echo url_for( $route, array_merge( $params, array( 'page' => $pager->getPreviousPage() ) ) ) . $anchor ?>" class="button prev"></a>
        <?php endif; ?>
        <?php if( !$pager->isLastPage() ): ?>
        <a href="<?php echo url_for( $route, array_merge( $params, array( 'page' => $pager->getNextPage() ) ) ) . $anchor ?>" class="button next"></a>
        <a href="<?php echo url_for( $route, array_merge( $params, array( 'page' => $pager->getLastPage() ) ) ) . $anchor ?>" class="button last"></a>
        <?php endif; ?>
        
        <table cellpadding="0" cellspacing="0">
            <tr>
                <?php foreach( $pager->getLinks() as $page ): ?>
                <td><a href="<?php echo  url_for( $route, array_merge( $params, array( 'page' => $page ) ) ) . $anchor ?>"<?php if( $pager->getPage() == $page ) echo ' class="current"';?>><?php echo $page ?></a></td>
                <?php endforeach; ?>
            </tr>
        </table>
    </div>

<?php endif; ?>